<template>
  <div class="box">
    数据分析页面
    <!-- <el-button type="primary" @click="exportData">导出数据</el-button> -->
    <div ref="main" id="main"></div>
  </div>
</template>
 
<script>
import * as echarts from "echarts";

import leaveModel from "../model/Statistics/index";

export default {
  data() {
    return {
      xList: [],
      yList: [],
    };
  },
  methods: {
   
  },
  async mounted() {
    
    this.myChart = echarts.init(this.$refs.main);
    

    let { data } = await leaveModel.group(); //分组
    

    this.xList = data.result.map((item) => item._id);
    this.yList = data.result.map((item) => item.count);

    var option = {
      title: {
        text: "测试员BUG提交统计",
      }, 
      tooltip: {},
      legend: {
        data: ["次数"],
      },
      xAxis: {
        data: this.xList,
      },
      yAxis: {},
      series: [
        {
          name: "次数",
          type: "bar",
          barWidth: 30, //柱图宽度
          data: this.yList, 
        },
      ],
    };
   
    this.myChart.setOption(option);
  },
};
</script>

<style>
.box{
  font-size:20px;
  padding: 20px;
  font-weight: 600;
}
#main {
  width: 800px;
  height: 400px;
  margin: 50px auto;
}
</style>